package listbyorder.access101_200.test120;

import java.util.List;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/8 12:49
 */
public class Solution1 {

    // 方法一： 暴力递归
    public int minimumTotal(List<List<Integer>> triangle) {
        if (triangle == null) return 0;
        return getAns(triangle, 0, 0, triangle.size());
    }

    private int getAns(List<List<Integer>> triangle, int s, int level, int size) {
        if (level == size - 1) return triangle.get(level).get(s);
        return Math.min(getAns(triangle, s, level + 1, size), getAns(triangle, s + 1, level + 1, size)) + triangle.get(level).get(s);
    }
}
